package com.amex.uam.tasks;

import java.io.Writer;

import com.amex.SQL.Utils;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import com.thoughtworks.xstream.io.json.JsonWriter;

public class UserProfileMessage {

	private int status;
	private Object data;

	public UserProfileMessage() {
		status = UserProfileServiceConstant.RESPONSE_OK;
	}
	public UserProfileMessage(int status) {
		this.status = status;
	}
	
	public int getStatus() {
		return status;
	}

	public UserProfileMessage setStatus(int status) {
		this.status = status;
		return this;
	}

	public Object getData() {
		return data;
	}

	public UserProfileMessage setData(Object data) {
		this.data = data;
		return this;
	}

	/**
	 * @deprecated
	 */
	public String directToJSON() {
		StringBuffer sb= new StringBuffer("{")
		.append("'status':").append(UserProfileServiceConstant.RESPONSE_OK).append(",")
		.append("'data': ").append(data)
		.append("}");
		return sb.toString();
	}
	/**
	 * @deprecated use gson
	 */
	public String toJSON() {
		XStream xstream = new XStream(new JsonHierarchicalStreamDriver() {
			public HierarchicalStreamWriter createWriter(Writer out) {
				return new JsonWriter(out, JsonWriter.DROP_ROOT_MODE);
			}
		});
		// xstream.setMode(XStream.NO_REFERENCES);
		// xstream.alias("student", UserProfile.class);
		return xstream.toXML(this);
	}
	
	public static void main(String[] args) {
		UserProfileMessage message = new UserProfileMessage();
		UserProfile bean = new UserProfile();
		message.setData(bean);
		
		System.out.println(message.toJSON());
	}
}
